Skip to content

feat: implement ow-exporter for Overwatch 2 statistics#440

Open
lexfrei wants to merge 14 commits intomasterfrom
feat/ow-exporter-implementation
Open

feat: implement ow-exporter for Overwatch 2 statistics#440
lexfrei wants to merge 14 commits intomasterfrom
feat/ow-exporter-implementation

Conversation

@lexfrei
Copy link
Owner

@lexfrei lexfrei commented Sep 23, 2025

Summary

Initial implementation of ow-exporter for Overwatch 2 profile statistics scraping and Prometheus metrics export.

Changes

  • Project Structure: Created cmd/ow-exporter/ with complete architecture
  • Analysis Complete: Platform separation (PC/Console) and 15 core metrics identified
  • HTML Parser: Implemented parser supporting both platforms and game modes
  • Metrics Mapping: Hardcoded 15 metrics with CSS selectors and Prometheus names
  • Documentation: Comprehensive README with API docs and usage examples

Features Implemented ✅

  • Platform analysis (PC/Console separation)
  • Game mode analysis (Quick Play/Competitive)
  • 15 core metrics mapping with CSS selectors
  • HTML parser structure for both platforms
  • Prometheus label structure design
  • Project documentation

Next Steps 🚧

  • REST API implementation
  • SQLite user storage
  • Background scheduler
  • Prometheus metrics exporter
  • Rate limiting and error handling
  • Container build configuration

Architecture

cmd/ow-exporter/
├── README.md         # Documentation and API reference
├── main.go          # Application entry point
├── models.go        # Hardcoded metrics and data structures  
├── parser.go        # HTML parsing with platform support
└── ANALYSIS.md      # Detailed platform structure analysis

Prometheus Metrics Preview

ow_hero_time_played_seconds{username="player1", hero="mercy", platform="pc", gamemode="competitive"} 15540
ow_hero_win_percentage{username="player1", hero="mercy", platform="pc", gamemode="competitive"} 67.5

API Endpoints Planned

  • GET /api/users - List tracked users
  • POST /api/users - Add user (username + profile_id)
  • GET /metrics - Prometheus metrics
  • GET /health - Health check

Closes #439

🤖 Generated with Claude Code

- Add README.md with feature overview and API documentation
- Add models.go with hardcoded metrics mapping for 15 core metrics
- Add parser.go with HTML parsing logic for PC/Console platforms
- Add ANALYSIS.md with detailed platform structure analysis
- Add main.go placeholder for development tracking

Related to #439

Co-Authored-By: Claude <noreply@anthropic.com>
lexfrei and others added 13 commits September 23, 2025 22:04
- Fix main function conflict between main.go and parser.go
- Remove unused variable in parser example function
- Run go mod tidy to update dependencies
- Verify successful compilation and execution

Related to #439

Co-Authored-By: Claude <noreply@anthropic.com>
- Replace simple output with full HTTP server using Echo framework
- Add structured logging with slog (following project standards)
- Implement placeholder API endpoints:
  - GET / - service info and documentation links
  - GET /health - health check
  - GET /api/users - user management (placeholder)
  - GET /metrics - Prometheus metrics (basic implementation)
- Add graceful shutdown with signal handling
- Use port 9420 (configurable via PORT env var)
- Add middleware: logging, recovery, CORS
- Update .gitignore to exclude ow-exporter binary

Tested endpoints:
- http://localhost:9420/ - ✅ service info
- http://localhost:9420/health - ✅ health check
- http://localhost:9420/api/users - ✅ placeholder response
- http://localhost:9420/metrics - ✅ Prometheus format

Related to #439

Co-Authored-By: Claude <noreply@anthropic.com>
Container Build:
- Add Containerfile following project standards (Go 1.25.1, Alpine 3.22, upx compression)
- Multi-stage build: golang:alpine -> scratch for minimal image size
- Non-root security: runs as 'nobody' user
- Port 9420 exposed for HTTP server
- SSL certificates included for HTTPS requests

GitHub Actions:
- Add ow-exporter.yaml workflow for automated container builds
- Multi-platform support: linux/amd64, linux/arm64
- GitHub Container Registry integration (ghcr.io/lexfrei/ow-exporter)
- Build triggers: changes to cmd/ow-exporter, build/ow-exporter, go.mod, go.sum
- Conditional push: only on master branch

Documentation:
- Update cmd/ow-exporter/README.md with Docker usage examples
- Add ow-exporter to main README.md in Web Services section
- Status: 🚧 Development (consistent with current state)
- Container: ghcr.io/lexfrei/ow-exporter

Image Features:
- Compressed binary with upx --best --lzma
- Scratch-based for minimal attack surface
- SSL/TLS support for external API calls
- Environment-configurable PORT (default: 9420)

Ready for:
- Automated container builds on every PR/push
- Production deployment via container registry
- Docker-based development and testing

Related to #439

Co-Authored-By: Claude <noreply@anthropic.com>
…metheus metrics

Implement comprehensive Overwatch profile parsing system with multi-backend support:
- Add Prometheus metrics export for all hero statistics
- Implement multiple parsers: browser automation, HTML parsing, API inspection
- Add robust error handling, type resolution, and runtime configuration
- Support competitive and quick play statistics extraction
- Add extensive testing coverage and metric validation
- Update dependencies and vendor directory for Prometheus client

Co-Authored-By: Claude <noreply@anthropic.com>
Fix critical linting issues to pass CI pipeline:
- Add missing periods to comment endings (godot)
- Replace nil with http.NoBody in HTTP requests (gocritic)
- Break down long functions into smaller components (funlen)
- Fix method ordering to place exported methods first (funcorder)
- Use http.MethodGet instead of string literal
- Apply gofmt formatting to all files

Significantly reduce linting errors from 10 critical issues to minor cosmetic ones.

Co-Authored-By: Claude <noreply@anthropic.com>
Major improvements to pass golangci-lint CI pipeline:
- Break down long functions (funlen): Split AnalyzeJSLoadedContent and tryPuppeteer into smaller methods
- Add missing comment periods (godot): Fixed all comment formatting issues
- Apply gofumpt formatting: Consistent code formatting across all files
- Split long lines (lll): Break User-Agent and other long strings across lines
- Fix method ordering (funcorder): Some method ordering issues remain but critical funlen errors resolved

Significantly reduced linting errors from 43 to 33, with all critical blocking issues resolved.
The remaining issues are mostly cosmetic (magic numbers, unused parameters).

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix comment periods (godot): add periods to all comment endings
- Fix function ordering (funcorder): move exported methods before unexported
- Fix unused parameters (revive): remove or prefix unused parameters with _
- Fix magic numbers (mnd): extract constants for numeric literals
- Fix long lines (lll): break long lines and improve formatting
- Fix gofmt issues: ensure proper code formatting
- Fix nlreturn: add blank lines before return statements
- Fix unparam: remove unused error return from saveJSONToFile
- Fix wrapcheck: wrap os.ReadFile error with context
- Remove unused functions to clean up codebase

All linting errors resolved - zero tolerance policy enforced.

Co-Authored-By: Claude <noreply@anthropic.com>
- NEVER disable GPG signing for commits - security requirement
- Fix GPG agent instead of bypassing with --no-gpg-sign
- All commits must be signed with F57F85FC7975F22BBC3F25049C173EB1B531AA1F

Co-Authored-By: Claude <noreply@anthropic.com>
- Resolve go.mod merge conflicts
- Update vendor directory after dependency changes
- Fix CLAUDE.md Git Security Standards section

Co-Authored-By: Claude <noreply@anthropic.com>
- Git security rules belong in global ~/CLAUDE.md, not project-specific
- Remove duplicate GPG signing policy from project CLAUDE.md

Co-Authored-By: Claude <noreply@anthropic.com>
- Add gopkg.in/yaml.v3 vendor files after dependency update
- Complete vendor directory sync after merge

Co-Authored-By: Claude <noreply@anthropic.com>
- Document all golangci-lint rules that must be followed
- Add specific guidance for common linting errors
- Ensure future Go development follows quality standards
- Prevent need for post-development linting fixes

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: implement ow-exporter for Overwatch 2 profile statistics

1 participant